package com.paic.custserv.web.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import com.paic.custserv.service.impl.CussWorkOrderServiceImpl;

public class InitListener  implements ServletContextListener {
	
	private static final Logger logger = LoggerFactory.getLogger(InitListener.class);
	private static ApplicationContext applicationContext = null;

	@Override
	public void contextDestroyed(ServletContextEvent servletCont) {
		
	}
	
	public static ApplicationContext getApplicationContext() {
		return applicationContext;
	}

	@Override
	public void contextInitialized(ServletContextEvent servletCont) {	
		applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletCont.getServletContext());
		CussWorkOrderServiceImpl cussWorkOrderServiceImpl = (CussWorkOrderServiceImpl)applicationContext.getBean("cussWorkOrderService");
		cussWorkOrderServiceImpl.getLatesAlltWorkOrderHandlers();
	}     	
	
}
